package com.gxgeek.springdata.domain.jpa.service;

import com.gxgeek.springdata.domain.jpa.Employee;
import com.gxgeek.springdata.domain.jpa.repository.EmployeeRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.ArrayList;
import java.util.List;

@Service
public class EmployeeService {

    @Autowired
    private EmployeeRepository employeeRepository;

    @Transactional
    public void update(String id, Integer age) {
        employeeRepository.update(id, age);
    }
    @Transactional
    public void update2(Integer id, Integer age) {
        employeeRepository.update2(id, age);
    }

    @Transactional
    public void insertList(){
        List<Employee> list = new ArrayList<>();
        for (int i = 0 ;i<100;i++){
            Employee employee = new Employee();
            employee.setAge(21);
            employee.setName("gaoisn");
        }
        employeeRepository.save(list);
    }

}
